package com.ts.base.util;

import com.ts.base.config.CustomException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class ExceptionManager {
    @Resource
    Environment environment;

    protected static Logger logger= LoggerFactory.getLogger(ExceptionManager.class);

    public CustomException create(String code){
        return new CustomException(code,environment.getProperty(code)==null?"异常代码未维护！请联系管理员"+code:environment.getProperty(code));

    }
}
